/*
 * Powered By dico
 * Since 2017 - 2018
 */package com.seeyoui.kensite.bussiness.report.userStat.service;
 
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.seeyoui.kensite.bussiness.report.userStat.domain.UserStat;
import com.seeyoui.kensite.bussiness.report.userStat.persistence.UserStatMapper;
import com.seeyoui.kensite.common.base.service.BaseService;
import com.seeyoui.kensite.common.exception.CRUDException;

/**
 * UserStat
 * @author dico
 * @version 2.0
 * @since 1.0
 * @date 2018-01-12
 */

@Service
public class UserStatService extends BaseService {
	
	@Autowired
	private UserStatMapper userStatMapper;

	/**
	 * 根据ID查询单条数据
	 * @param id
	 * @return
	 * @throws CRUDException
	 */
	public UserStat findOne(String id) throws CRUDException{
		return userStatMapper.findOne(id);
	}
	
	/**
	 * 查询数据集合
	 * @param userStat
	 * @return
	 * @throws CRUDException
	 */
	public List<UserStat> findList(UserStat userStat) throws CRUDException {
		return userStatMapper.findList(userStat);
	}
	
	/**
	 * 查询所有数据集合
	 * @param userStat
	 * @return
	 * @throws CRUDException
	 */
	public List<UserStat> findAll(UserStat userStat) throws CRUDException {
		return userStatMapper.findAll(userStat);
	}
	
	/**
	 * 查询数据总数
	 * @param userStat
	 * @return
	 * @throws CRUDException
	 */
	public int findTotal(UserStat userStat) throws CRUDException {
		return userStatMapper.findTotal(userStat);
	}
	
	/**
	 * 查询数据总数排除当前数据
	 * @param userStat
	 * @return
	 * @throws CRUDException
	 */
	public int findExTotal(UserStat userStat) throws CRUDException {
		return userStatMapper.findExTotal(userStat);
	}
	
	/**
	 * 数据新增
	 * @param userStat
	 * @throws CRUDException
	 */
	public void save(UserStat userStat) throws CRUDException{
		userStat.preInsert();
		userStatMapper.save(userStat);
	}
	
	/**
	 * 数据修改
	 * @param userStat
	 * @throws CRUDException
	 */
	public void update(UserStat userStat) throws CRUDException{
		userStat.preUpdate();
		userStatMapper.update(userStat);			
	}
	
	/**
	 * 数据删除
	 * @param listId
	 * @throws CRUDException
	 */
	public void delete(List<String> listId) throws CRUDException {
		userStatMapper.delete(listId);
	}
	
	/**
	 * 数据假删除
	 * @param userStat
	 * @throws CRUDException
	 */
	public void remove(UserStat userStat) throws CRUDException{
		userStat.preUpdate();
		userStatMapper.remove(userStat);			
	}
	
	/**
	 * 查询指定用户ID的统计记录
	 * @param userId
	 * @return
	 * @throws CRUDException
	 */
	public UserStat findByUserId(String userId) throws CRUDException{
		return userStatMapper.findByUserId(userId);
	}
	
	/**
	 * 获取积分排名前20名
	 * @return
	 * @throws CRUDException
	 */
	public List<UserStat> findTop20() throws CRUDException {
		return userStatMapper.findTop20();
	}
	
	/**
	 * 获取全部积分排名
	 * @return
	 * @throws CRUDException
	 */
	public List<UserStat> findAllRank() throws CRUDException {
		return userStatMapper.findAllRank();
	}
	
}